(when (>= emacs-major-version 24)
  (require 'package)
  (package-initialize)
  (setq package-archives '(
                           ("gnu"   . "http://elpa.emacs-china.org/gnu/")
                           ("melpa" . "http://elpa.emacs-china.org/melpa/")
                           ("org"   . "http://elpa.emacs-china.org/org/"))))

(require 'cl)

(defvar damacs/damacs-packages '(
				 better-defaults
				 use-package
				 window-numbering
				 which-key
				 solarized-theme
				 ))

(setq damacs-selected-packages damacs/damacs-packages)

(defun damacs/damacs-packages-install ()
  (loop for pkg in damacs/damacs-packages
	when (not (package-installed-p pkg)) do (return nil)
	finally (return t)))

(unless (damacs/damacs-packages-install)
  (message "%s" "Refreshing package database...")
  (package-refresh-contents)
  (dolist (pkg damacs/damacs-packages)
    (when (not (package-installed-p pkg))
      (package-install pkg))))

(provide 'damacs-packages)
